//
//  JWAddressBookNewFriendsVC.m
//  jinwang
//
//  Created by jzb on 2018/3/29.
//  Copyright © 2018年 jzb. All rights reserved.
//

#import "JWAddressBookNewFriendsVC.h"
#import "JWAddressBookContactsCell.h"
#import "JWAddressBookContactsModel.h"

@interface JWAddressBookNewFriendsVC ()

@property (nonatomic,strong) JWAddressBookContactsCell *cell;

@property (nonatomic,strong) NSMutableArray *ListmodelArr;

@end

@implementation JWAddressBookNewFriendsVC

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setUpTableView];
    [self makeUrl_newFriends];
}
//配置tableView
-(void)setUpTableView{
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.tableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    //注册cell
    
    [self registerCellWithCellClassArray:@[NSStringFromClass([JWAddressBookContactsCell class])]];
    
    //索引
    //    [self.tableView setSectionIndexBackgroundColor:[UIColor clearColor]];//索引条的颜色
    self.tableView.sectionIndexBackgroundColor = [UIColor clearColor];
    [self.tableView setSectionIndexTrackingBackgroundColor:[UIColor clearColor]];//选中时，索引条的颜色
    [self.tableView setSectionIndexColor:[UIColor grayColor]];//索引条文字的颜色
}
#pragma mark -UITableViewDelegate,UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.ListmodelArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    self.cell = [tableView dequeueReusableCellWithIdentifier:[JWAddressBookContactsCell getCellReuseIdentifier]];
    self.cell.contentView.backgroundColor = [UIColor clearColor];
    
    JWAddressBookContactsModel *model = self.ListmodelArr[indexPath.row];
    self.cell.CellType = @"NewFriends";
    self.cell.model = model;
    
    
    return self.cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 61;
}

#pragma mark -网络请求
-(void)makeUrl_newFriends{
    
    [[DDNetworkManagerDate makeUrl_newFriends_with_token:k_user_token] post_RequestFinshSuccess:^(id responseObject) {
        
        NSLog(@"----->>%@",responseObject);
        if ([self requestFinshCode:responseObject isShowMessage:YES] == 1) {
            
            NSArray *data = [responseObject objectForKey:kRequsetDataKey];
            //转模型
            NSMutableArray *arr = [NSMutableArray array];
            [data enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                JWAddressBookContactsModel *model = [JWAddressBookContactsModel yy_modelWithDictionary:obj];
                [arr addObject:model];
            }];
            self.ListmodelArr = arr.mutableCopy;
            
        }
        [self.tableView reloadData];
    } failure:^(id errorObject) {
        [self showBottomMessag:@"网络请求失败"];
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
